﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package GameMode {
    import flash.events.*;
    import Engine.Managers.*;
    import flash.display.*;
    import flash.geom.*;
    import Engine.Helpers.*;
    import Events.*;
    import Classes.*;
    import Transactions.*;
    import Classes.util.*;
    import Classes.sim.*;
    import com.greensock.*;
    import Display.*;
    import Display.MarketUI.*;
    import flash.text.*;
    import Modules.guide.ui.*;
    import Engine.*;
    import Modules.stats.types.*;
    import com.zynga.skelly.util.*;

    public class GMObjectMove extends GameMode {

        protected static const TILE_OUTLINE_WIDTH:int = 2;
        public static const BONUS_TEXT_SIZE:int = 20;
        public static const BONUS_TEXT_INCREASE:Number = 1.1;
        public static const BONUS_FADE_IN:Number = 0.5;
        public static const BONUS_FADE_OUT:Number = 0.5;
        public static const MOVE_TWEEN_TIME:Number = 0.2;
        public static const COLOR_NO_ROAD_CONNECT:uint = 16496919;

        public static var USE_TILES:Boolean = true;
        public static var SHOW_AREAS_AFFECTING_OBJECT:Boolean = false;

        public const LINE_ALPHA:Number = 0.5;
        public const LINE_WIDTH:Number = 0.5;

        protected var m_isGift:Boolean = false;
        protected var m_cid:int;
        protected var m_highlightedPoint:Point;
        protected var m_selectedObject:GameObject = null;
        protected var m_positionValid:Boolean = false;
        protected var m_collisions:Array;
        protected var m_objectStartPos:Vector3 = null;
        protected var m_objectStartDirection:int;
        protected var m_releasedPoint:Vector2 = null;
        protected var m_objectPlacedSuccess:Boolean = false;
        protected var m_objectStoredSuccess:Boolean = false;
        protected var m_dropImmediately:Boolean = false;
        protected var m_validStorageClasses:Array;
        private var m_dragStartPos:Point;
        protected var m_objectDragOffset:Point;
        protected var m_viewDragStartPos:Point = null;
        protected var m_dragging:Boolean = false;
        protected var m_oldState:String;
        protected var m_oldDirection:int;
        protected var m_storedOrigin:int = 0;
        protected var m_mouseDownFlag:Boolean = false;
        protected var m_onPlaceCollisions:Array;
        protected var m_onPlaceFilter:int;
        protected var m_displayBonusObject:Sprite;
        protected var m_displayTextObj:TextField;
        protected var m_displayTextObj2:TextField;
        protected var m_textFormat:TextFormat;
        protected var m_textYOffset:int;
        protected var m_moveHelperList:Array;
        protected var m_prevPos:Point;
        protected var m_curBonus:ItemBonus;
        protected var m_coinIcon:Bitmap;
        protected var m_autoRotate:Boolean;
        protected var m_preview:DisplayObject;
        private var m_areasOfEffect:Array;
        private var m_aoEffectObjects:Array;
        private var m_alternatingGrantReceive:Boolean = false;
        private var m_selectedLocked:Boolean = false;
        private var m_exitAfterDrop:Boolean = false;
        private var m_backupStartPosition:Vector3;
        private var m_linkedObjectMode:Boolean = false;
        protected var m_canPlaceOnRoadOrNearRoad:Boolean = false;
        protected var m_canPlaceToFriendHome:Boolean = false;
        protected var m_isNearRoad:Boolean = false;
        protected var m_positionFeedback:Shape = null;

        public function GMObjectMove(_arg1:GameObject, _arg2:String=null, _arg3:Point=null, _arg4:int=-1, _arg5:Boolean=false, _arg6:Vector3=null){
            var _local7:Vector2;
            var _local8:Point;
            this.m_collisions = [];
            this.m_validStorageClasses = new Array();
            this.m_displayBonusObject = new Sprite();
            this.m_moveHelperList = new Array();
            this.m_prevPos = new Point();
            this.m_areasOfEffect = new Array();
            this.m_aoEffectObjects = new Array();
            if (((!(this.m_linkedObjectMode)) && ((Global.world.getTopGameMode() is GMObjectMove)))){
                Global.world.popGameMode();
            };
            this.m_selectedObject = _arg1;
            this.m_oldState = _arg2;
            this.m_oldDirection = _arg4;
            this.m_exitAfterDrop = _arg5;
            this.resetOnPlaceCollisions();
            this.m_viewDragStartPos = _arg3;
            if (this.m_selectedObject){
                if (_arg6){
                    this.m_backupStartPosition = _arg6;
                };
                this.m_objectStartPos = _arg1.getPosition();
                _local7 = IsoMath.tilePosToPixelPos(this.m_objectStartPos.x, this.m_objectStartPos.y);
                _local8 = new Point(_local7.x, _local7.y);
                _local8 = IsoMath.viewportToStage(_local8);
                this.m_objectStartDirection = this.m_selectedObject.getDirection();
                this.m_objectDragOffset = getMouseStagePos().subtract(_local8);
                if (_arg4 == Constants.INDEX_NONE){
                    this.m_oldDirection = this.m_selectedObject.getDirection();
                };
                this.registerAllOnPlaceCollisions();
            };
            super();
            m_showMousePointer = true;
            m_cursorImage = EmbeddedArt.hud_act_move;
            this.m_coinIcon = new EmbeddedArt.smallCoinIcon();
            this.m_coinIcon.visible = false;
            this.m_autoRotate = true;
            this.m_displayTextObj = new StrokeTextField(0, 0.4);
            this.m_displayTextObj.embedFonts = true;
            this.m_displayTextObj.autoSize = TextFieldAutoSize.LEFT;
            this.m_textFormat = new TextFormat(EmbeddedArt.TITLE_FONT, 7, EmbeddedArt.TEXT_MAIN_COLOR, true);
            this.m_displayTextObj2 = new StrokeTextField(EmbeddedArt.TEXT_BACKGROUND_COLOR, 0.4);
            this.m_displayTextObj2.embedFonts = true;
            this.m_displayTextObj2.autoSize = TextFieldAutoSize.RIGHT;
            this.m_displayBonusObject.addChild(this.m_displayTextObj);
            this.m_displayBonusObject.addChild(this.m_displayTextObj2);
            this.m_displayBonusObject.addChild(this.m_coinIcon);
            this.m_displayBonusObject.alpha = 0;
            TweenLite.to(this.m_displayBonusObject, BONUS_FADE_IN, {alpha:1});
            m_uiMode = UIEvent.MOVE;
        }
        public static function getCoinLabel(_arg1:MapResource):String{
            var _local2:String = _arg1.getTypeName();
            if (_local2 == "residence"){
                return (ZLoc.t("Main", "Rent"));
            };
            if (_local2 == "business"){
                return (ZLoc.t("Main", "Meals"));
            };
            return ("");
        }
        public static function getSmallBonusTextSize():Number{
            var _local1:Number = (GMObjectMove.BONUS_TEXT_SIZE / GlobalEngine.viewport.getZoom());
            return (_local1);
        }
        public static function getLargeBonusTextSize():Number{
            var _local1:Number = (getSmallBonusTextSize() * BONUS_TEXT_INCREASE);
            return (_local1);
        }
        public static function getPixelCenter(_arg1:ItemInstance):Point{
            var _local2:Vector3 = _arg1.getPosition();
            var _local3:Vector3 = _arg1.getSize();
            return (IsoMath.tilePosToPixelPos((_local2.x + (_local3.x / 2)), (_local2.y + (_local3.y / 2))));
        }
        public static function bonusColor(_arg1:MapResource):uint{
            var _local2:int = ItemBonus.getBonusModifier(_arg1, ItemBonus.ALL);
            if (_local2 > 0){
                return (Constants.COLOR_HIGHLIGHT_BLUE);
            };
            if (_local2 < 0){
                return (Constants.COLOR_NOT_VALID_PLACEMENT);
            };
            return (4294967295);
        }

        public function getSelectedObject():GameObject{
            return (this.m_selectedObject);
        }
        protected function registerAllOnPlaceCollisions():void{
        }
        public function doImmediateDrop():void{
            this.m_dropImmediately = true;
        }
        private function getWaveScale(_arg1:Number):Number{
            var _local2:Number = ((Constants.TILE_WIDTH * ConsumerShockwave.ORTHO_FACTOR) / 200);
            return ((_local2 * _arg1));
        }
        public function startWavePreview(_arg1:DisplayObject, _arg2:Number, _arg3:Point, _arg4:uint):DisplayObject{
            var _local5:DisplayObject = new EmbeddedArt.businessShockwavePreview();
            new EmbeddedArt.businessShockwavePreview().scaleX = (_local5.scaleY = 0);
            _local5.x = _arg3.x;
            _local5.y = _arg3.y;
            var _local6:Sprite = (Global.world.getObjectLayerByName("road").getDisplayObject() as Sprite);
            _local6.addChild(_local5);
            var _local7:ColorTransform = _local5.transform.colorTransform;
            _local7.color = _arg4;
            _local5.transform.colorTransform = _local7;
            var _local8:Number = this.getWaveScale(_arg2);
            TweenLite.to(_local5, (BONUS_FADE_IN / 2), {
                scaleX:_local8,
                scaleY:_local8
            });
            return (_local5);
        }
        public function startAOEPreview(_arg1:ItemInstance, _arg2:Number, _arg3:Point, _arg4:uint):DisplayObject{
            var _local15:Point;
            var _local17:Array;
            var _local18:int;
            var _local19:int;
            var _local20:Number;
            var _local21:Number;
            var _local22:Number;
            var _local5:Shape = new Shape();
            _local5.alpha = 0;
            _local5.x = _arg3.x;
            _local5.y = _arg3.y;
            var _local6:Sprite = (Global.world.getObjectLayerByName("road").getDisplayObject() as Sprite);
            _local6.addChild(_local5);
            var _local7:Vector3 = _arg1.getSize();
            var _local8:Vector3 = _arg1.getPosition();
            var _local9:Point = IsoMath.getPixelDeltaFromTileDelta(1, 0);
            var _local10:Point = IsoMath.getPixelDeltaFromTileDelta(0, 1);
            var _local11:int = -(_arg2);
            var _local12:int = (_local7.x + _arg2);
            var _local13:int = -(_arg2);
            var _local14:int = (_local7.y + _arg2);
            var _local16:Boolean;
            if (_local16){
                _local5.graphics.lineStyle(1, _arg4, 0.75);
                _local15 = IsoMath.getPixelDeltaFromTileDelta(_local11, _local13);
                _local5.graphics.moveTo(_local15.x, _local15.y);
                _local15 = IsoMath.getPixelDeltaFromTileDelta(_local12, _local13);
                _local5.graphics.lineTo(_local15.x, _local15.y);
                _local15 = IsoMath.getPixelDeltaFromTileDelta(_local12, _local14);
                _local5.graphics.lineTo(_local15.x, _local15.y);
                _local15 = IsoMath.getPixelDeltaFromTileDelta(_local11, _local14);
                _local5.graphics.lineTo(_local15.x, _local15.y);
                _local15 = IsoMath.getPixelDeltaFromTileDelta(_local11, _local13);
                _local5.graphics.lineTo(_local15.x, _local15.y);
            } else {
                _local17 = [];
                _local18 = _local11;
                while (_local18 < _local12) {
                    _local17[_local18] = [];
                    _local19 = _local13;
                    while (_local19 < _local14) {
                        if ((((((((_local18 >= 0)) && ((_local18 < _local7.x)))) && ((_local19 >= 0)))) && ((_local19 < _local7.y)))){
                            _local17[_local18][_local19] = true;
                        } else {
                            _local20 = ((_local18 + 0.5) - (_local7.x * 0.5));
                            _local21 = ((_local19 + 0.5) - (_local7.y * 0.5));
                            _local22 = Math.sqrt(((_local20 * _local20) + (_local21 * _local21)));
                            if (_local22 > (_arg2 + 0.5)){
                            } else {
                                _local17[_local18][_local19] = true;
                                _local15 = IsoMath.getPixelDeltaFromTileDelta(_local18, _local19);
                                _local5.graphics.moveTo(_local15.x, _local15.y);
                                _local5.graphics.lineTo((_local15.x + _local9.x), (_local15.y + _local9.y));
                                _local5.graphics.lineTo(((_local15.x + _local9.x) + _local10.x), ((_local15.y + _local9.y) + _local10.y));
                                _local5.graphics.lineTo((_local15.x + _local10.x), (_local15.y + _local10.y));
                                _local5.graphics.lineTo(_local15.x, _local15.y);
                                _local5.graphics.endFill();
                            };
                        };
                        _local19++;
                    };
                    _local18++;
                };
                _local5.graphics.lineStyle(1, _arg4, 0.75);
                _local18 = _local11;
                while (_local18 < _local12) {
                    _local19 = _local13;
                    while (_local19 < _local14) {
                        if (_local17[_local18][_local19] != true){
                        } else {
                            _local15 = IsoMath.getPixelDeltaFromTileDelta(_local18, _local19);
                            if ((((_local18 == -(_arg2))) || (!((_local17[(_local18 - 1)][_local19] == true))))){
                                _local5.graphics.moveTo(_local15.x, _local15.y);
                                _local5.graphics.lineTo((_local15.x + _local10.x), (_local15.y + _local10.y));
                            };
                            if ((((_local18 == (_local12 - 1))) || (!((_local17[(_local18 + 1)][_local19] == true))))){
                                _local5.graphics.moveTo((_local15.x + _local9.x), (_local15.y + _local9.y));
                                _local5.graphics.lineTo(((_local15.x + _local9.x) + _local10.x), ((_local15.y + _local9.y) + _local10.y));
                            };
                            if (_local17[_local18][(_local19 - 1)] != true){
                                _local5.graphics.moveTo(_local15.x, _local15.y);
                                _local5.graphics.lineTo((_local15.x + _local9.x), (_local15.y + _local9.y));
                            };
                            if (_local17[_local18][(_local19 + 1)] != true){
                                _local5.graphics.moveTo((_local15.x + _local10.x), (_local15.y + _local10.y));
                                _local5.graphics.lineTo(((_local15.x + _local9.x) + _local10.x), ((_local15.y + _local9.y) + _local10.y));
                            };
                        };
                        _local19++;
                    };
                    _local18++;
                };
            };
            TweenLite.to(_local5, (BONUS_FADE_IN / 2), {alpha:1});
            return (_local5);
        }
        public function positionFeedback(_arg1:ItemInstance, _arg2:Point):Shape{
            var _local20:Point;
            var _local21:Point;
            var _local22:Point;
            var _local27:int;
            var _local28:MapResource;
            var _local29:int;
            var _local30:int;
            var _local31:Number;
            var _local32:Number;
            var _local33:Number;
            var _local34:Number;
            var _local35:Number;
            var _local3:Shape = this.m_positionFeedback;
            if (_local3 == null){
                _local3 = new Shape();
                _local28 = (this.m_selectedObject as MapResource);
                if (((_local28) && (!((_local28.getItem().type == "road"))))){
                    if (!this.m_selectedLocked){
                        this.m_selectedObject.lock();
                        this.m_selectedLocked = true;
                    };
                };
                _local29 = GlobalEngine.viewport.overlayBase.numChildren;
                if (_local29 > 1){
                    _local29--;
                };
                GlobalEngine.viewport.overlayBase.addChildAt(_local3, _local29);
                _local3.alpha = 0;
            };
            _local3.x = _arg2.x;
            _local3.y = _arg2.y;
            var _local4:Vector3 = _arg1.getSize();
            var _local5:Number = _local4.y;
            if (_local4.x > _local4.y){
                _local5 = _local4.x;
            };
            var _local6:Vector3 = _arg1.getPosition();
            var _local7:Point = IsoMath.getPixelDeltaFromTileDelta(1, 0);
            var _local8:Point = IsoMath.getPixelDeltaFromTileDelta(0, 1);
            var _local9 = 5;
            var _local10:int = -(_local9);
            var _local11:int = (_local5 + _local9);
            var _local12:int = ((_local5 - _local4.x) / 2);
            _local10 = (_local10 - _local12);
            _local11 = (_local11 - _local12);
            var _local13:int = -(_local9);
            var _local14:int = (_local5 + _local9);
            _local12 = ((_local5 - _local4.y) / 2);
            _local13 = (_local13 - _local12);
            _local14 = (_local14 - _local12);
            _local3.graphics.clear();
            var _local15:Number = ((((_local14 - _local13) - (2 * _local9)) - 0.5) / 2);
            var _local16:uint = (this.m_positionValid) ? Constants.COLOR_VALID_PLACEMENT : Constants.COLOR_NOT_VALID_PLACEMENT;
            if (this.m_positionValid){
                _local16 = 1148945;
            };
            if ((((_arg1 is MapResource)) && ((true == (_arg1 as MapResource).isNotAtRoad())))){
                _local16 = Constants.COLOR_NOT_VALID_PLACEMENT;
            };
            var _local17:Rectangle = new Rectangle(0, 0, 1, 1);
            var _local18:Rectangle = new Rectangle();
            var _local19:Matrix = new Matrix();
            var _local23:Array = [];
            var _local24:Array = [];
            var _local25:Array = [];
            var _local26:int = _local10;
            while (_local26 <= _local11) {
                _local20 = IsoMath.getPixelDeltaFromTileDelta(_local26, _local13);
                _local21 = IsoMath.getPixelDeltaFromTileDelta(_local26, _local14);
                _local19.createGradientBox((_local21.x - _local20.x), (_local21.y - _local20.y), 0, _local20.x, _local20.y);
                _local3.graphics.lineStyle(this.LINE_WIDTH, 0);
                _local30 = 0;
                _local23 = [];
                _local24 = [];
                _local25 = [];
                _local27 = _local13;
                while (_local27 <= _local14) {
                    _local31 = (_local26 - (_local4.x * 0.5));
                    _local32 = (_local27 - (_local4.y * 0.5));
                    _local33 = Math.sqrt(((_local31 * _local31) + (_local32 * _local32)));
                    _local33 = (_local33 - _local15);
                    _local34 = 1;
                    if (_local33 > 0){
                        _local34 = (1 - (_local33 / _local9));
                        if (_local34 < 0){
                            _local34 = 0;
                        };
                    };
                    _local23.push(_local16);
                    _local24.push(_local34);
                    _local25.push(((_local30 * 0xFF) / (_local14 - _local13)));
                    _local30++;
                    _local27++;
                };
                _local3.graphics.lineGradientStyle(GradientType.LINEAR, _local23, _local24, _local25, _local19);
                if ((((_local26 > 0)) && ((_local26 < _local4.x)))){
                    _local3.graphics.moveTo(_local20.x, _local20.y);
                    _local22 = IsoMath.getPixelDeltaFromTileDelta(_local26, 0);
                    _local3.graphics.lineTo(_local22.x, _local22.y);
                    _local22 = IsoMath.getPixelDeltaFromTileDelta(_local26, _local4.y);
                    _local3.graphics.moveTo(_local22.x, _local22.y);
                    _local3.graphics.lineTo(_local21.x, _local21.y);
                } else {
                    _local3.graphics.moveTo(_local20.x, _local20.y);
                    _local3.graphics.lineTo(_local21.x, _local21.y);
                };
                _local26++;
            };
            _local27 = _local13;
            while (_local27 <= _local14) {
                _local20 = IsoMath.getPixelDeltaFromTileDelta(_local10, _local27);
                _local21 = IsoMath.getPixelDeltaFromTileDelta(_local11, _local27);
                _local35 = 0;
                _local19.createGradientBox((_local21.x - _local20.x), (_local21.y - _local20.y), _local35, _local20.x, _local20.y);
                _local3.graphics.lineStyle(this.LINE_WIDTH, 0);
                _local30 = 0;
                _local23 = [];
                _local24 = [];
                _local25 = [];
                _local26 = _local10;
                while (_local26 <= _local11) {
                    _local31 = (_local26 - (_local4.x * 0.5));
                    _local32 = (_local27 - (_local4.y * 0.5));
                    _local33 = Math.sqrt(((_local31 * _local31) + (_local32 * _local32)));
                    _local33 = (_local33 - _local15);
                    _local34 = 1;
                    if (_local33 > 0){
                        _local34 = (1 - (_local33 / _local9));
                        if (_local34 < 0){
                            _local34 = 0;
                        };
                    };
                    _local23.push(_local16);
                    _local24.push(_local34);
                    _local25.push(((_local30 * 0xFF) / (_local14 - _local13)));
                    _local30++;
                    _local26++;
                };
                _local3.graphics.lineGradientStyle(GradientType.LINEAR, _local23, _local24, _local25, _local19);
                if ((((_local27 > 0)) && ((_local27 < _local4.y)))){
                    _local3.graphics.moveTo(_local20.x, _local20.y);
                    _local22 = IsoMath.getPixelDeltaFromTileDelta(0, _local27);
                    _local3.graphics.lineTo(_local22.x, _local22.y);
                    _local22 = IsoMath.getPixelDeltaFromTileDelta(_local4.x, _local27);
                    _local3.graphics.moveTo(_local22.x, _local22.y);
                    _local3.graphics.lineTo(_local21.x, _local21.y);
                } else {
                    _local3.graphics.moveTo(_local20.x, _local20.y);
                    _local3.graphics.lineTo(_local21.x, _local21.y);
                };
                _local27++;
            };
            TweenLite.to(_local3, (BONUS_FADE_IN / 2), {alpha:1});
            return (_local3);
        }
        public function startCloseShape(_arg1:ItemInstance):Shape{
            return (null);
        }
        public function fadeThenRemove(_arg1:DisplayObject):void{
            var preview:* = _arg1;
            if (preview == null){
                return;
            };
            var cont:* = Curry.curry(function (_arg1:DisplayObject):void{
                if (_arg1.parent != null){
                    _arg1.parent.removeChild(_arg1);
                };
            }, preview);
            TweenLite.to(preview, BONUS_FADE_OUT, {
                alpha:0,
                onComplete:cont
            });
        }
        private function matchBonus(_arg1:GameObject):Boolean{
            if ((((!(_arg1) is MapResource)) || ((MapResource(_arg1).getItem().acceptBonus == false)))){
                return (false);
            };
            var _local2:MapResource = MapResource(_arg1);
            if (!this.m_curBonus.bonusAppliesToObject(_local2)){
                return (false);
            };
            if (_local2 == this.m_selectedObject){
                return (false);
            };
            if (_local2.getParent() == this.m_selectedObject){
                return (false);
            };
            return (this.m_curBonus.withinRadius(_local2, MapResource(this.m_selectedObject)));
        }
        private function endAreasOfEffect():void{
            var _local1:DisplayObject;
            for each (_local1 in this.m_areasOfEffect) {
                this.fadeThenRemove(_local1);
            };
            this.m_areasOfEffect.length = 0;
            this.m_aoEffectObjects.length = 0;
        }
        private function showAreasOfEffect(_arg1:Array, _arg2:Array):void{
            var _local3:ItemBonus;
            var _local4:ItemInstance;
            var _local7:int;
            var _local9:Point;
            var _local10:Point;
            var _local11:DisplayObject;
            var _local5:Number = 0;
            var _local6:int;
            _local6 = 0;
            while (_local6 < _arg1.length) {
                _local4 = _arg2[_local6];
                _local3 = _arg1[_local6];
                if (this.m_aoEffectObjects.indexOf(_local4) >= 0){
                } else {
                    _local9 = getPixelCenter(_local4);
                    _local10 = IsoMath.tilePosToPixelPos(this.m_highlightedPoint.x, this.m_highlightedPoint.y);
                    _local7 = (_local3.isNegative()) ? Constants.COLOR_NOT_VALID_PLACEMENT : Constants.COLOR_VALID_PLACEMENT;
                    if (USE_TILES){
                        _local11 = this.startAOEPreview(_local4, _local3.radius, _local10, _local7);
                    } else {
                        _local11 = this.startWavePreview(this.m_displayBonusObject, _local3.effectiveRadius(_local4), _local9, _local7);
                    };
                    this.m_areasOfEffect.push(_local11);
                    this.m_aoEffectObjects.push(_local4);
                };
                _local6++;
            };
            var _local8:int;
            while (_local8 < this.m_aoEffectObjects.length) {
                _local4 = (this.m_aoEffectObjects[_local8] as MapResource);
                if (_arg2.indexOf(_local4) >= 0){
                } else {
                    this.m_aoEffectObjects.splice(_local8, 1);
                    if (_local8 < this.m_areasOfEffect.length){
                        _local11 = (this.m_areasOfEffect[_local8] as DisplayObject);
                        this.fadeThenRemove(_local11);
                        this.m_areasOfEffect.splice(_local8, 1);
                    };
                    _local8--;
                };
                _local8++;
            };
        }
        private function showBonusesAffectingMapObj(_arg1:MapResource, _arg2:Point):void{
            var _local8:ItemBonus;
            var _local10:String;
            var _local11:TextLineMetrics;
            if (_arg1.getItem().acceptBonus == false){
                return;
            };
            var _local3:Array = new Array();
            var _local4:Array = ItemBonus.getBonuses(_arg1, _local3);
            if (SHOW_AREAS_AFFECTING_OBJECT){
                this.showAreasOfEffect(_local4, _local3);
            };
            var _local5:Number = getSmallBonusTextSize();
            var _local6:Number = 0;
            var _local7:Boolean;
            for each (_local8 in _local4) {
                if (_local8.field == ItemBonus.COIN_YIELD){
                    if ((((_arg1 is Business)) && ((_local8.name == "FranchiseAOE")))){
                        if (!_local7){
                            _local6 = (_local6 + ItemBonus.calcFranchiseBonuses((_arg1 as Business)));
                            _local7 = true;
                        };
                    } else {
                        _local6 = (_local6 + _local8.percentModifier);
                    };
                };
            };
            if (this.m_textYOffset == 0){
                this.m_textYOffset = _local5;
            };
            var _local9:int = _arg1.getCoinYield();
            if (this.m_displayBonusObject.x == 0){
                this.m_displayBonusObject.x = _arg2.x;
                this.m_displayBonusObject.y = _arg2.y;
            };
            if (_local6){
                this.m_displayBonusObject.x = _arg2.x;
                this.m_displayBonusObject.y = _arg2.y;
                TweenLite.to(this.m_displayTextObj, 0.5, {alpha:1});
                this.m_textFormat.size = _local5;
                _local10 = "Bonus";
                if (_local6 < 0){
                    _local10 = "decreaseBonus";
                };
                this.m_displayTextObj.text = ((((ZLoc.t("Main", _local10) + "\n") + ((_local6 > 0)) ? "+" : "") + int(_local6)) + "%");
                this.m_textFormat.color = bonusColor(_arg1);
                this.m_textFormat.align = TextFormatAlign.CENTER;
                this.m_displayTextObj.setTextFormat(this.m_textFormat);
                _local11 = this.m_displayTextObj.getLineMetrics(0);
                this.m_displayTextObj.x = (-(_local11.width) / 2);
                this.m_displayTextObj.y = (-(_local11.height) * 1.5);
            } else {
                this.m_coinIcon.visible = false;
                TweenLite.to(this.m_displayTextObj, 0.5, {alpha:0});
            };
        }
        private function showPositioningFeedback(_arg1:MapResource, _arg2:Point):void{
            this.m_positionFeedback = this.positionFeedback(_arg1, _arg2);
        }
        private function showBonusesMapObjApplies(_arg1:MapResource, _arg2:Point):void{
            var _local3:ItemBonus;
            var _local4:String;
            var _local5:int;
            var _local8:GMObjMoveHelper;
            var _local9:Point;
            var _local11:Array;
            var _local12:String;
            var _local13:Item;
            var _local14:Boolean;
            var _local15:Array;
            var _local16:MapResource;
            var _local17:Number;
            var _local18:uint;
            var _local19:Point;
            var _local6:int;
            var _local7:Number = getSmallBonusTextSize();
            for each (_local8 in this.m_moveHelperList) {
                _local8.m_active = false;
            };
            _local9 = IsoMath.tilePosToPixelPos(this.m_highlightedPoint.x, this.m_highlightedPoint.y);
            if (this.m_positionValid){
                _local11 = [];
                if ((_arg1 is ConstructionSite)){
                    _local12 = (_arg1 as ConstructionSite).targetName;
                    _local13 = Global.gameSettings.getItemByName(_local12);
                    _local11 = _local13.bonuses;
                } else {
                    _local11 = _arg1.getItem().bonuses;
                };
                for each (_local3 in _local11) {
                    this.m_curBonus = _local3;
                    _local14 = _local3.isNegative();
                    _local5 = (_local14) ? Constants.COLOR_NOT_VALID_PLACEMENT : Constants.COLOR_HIGHLIGHT_BLUE;
                    if (_local14){
                        if (this.m_canPlaceOnRoadOrNearRoad){
                            _local5 = Constants.COLOR_HIGHLIGHT_BLUE;
                        } else {
                            _local5 = Constants.COLOR_NOT_VALID_PLACEMENT;
                        };
                        if (true == _arg1.isNotAtRoad()){
                            _local5 = Constants.COLOR_NOT_VALID_PLACEMENT;
                        };
                    };
                    if (this.m_preview == null){
                        if (USE_TILES){
                            this.m_preview = this.startAOEPreview(_arg1, this.m_curBonus.radius, _local9, _local5);
                        } else {
                            this.m_preview = this.startWavePreview(this.m_displayBonusObject, this.m_curBonus.effectiveRadius(_arg1), _arg2, _local5);
                        };
                    } else {
                        if (USE_TILES){
                            TweenLite.to(this.m_preview, 0.3, {
                                x:_local9.x,
                                y:_local9.y,
                                alpha:1
                            });
                        } else {
                            _local17 = this.getWaveScale(this.m_curBonus.effectiveRadius(_arg1));
                            TweenLite.to(this.m_preview, 0.3, {
                                x:_arg2.x,
                                y:_arg2.y,
                                scaleX:_local17,
                                scaleY:_local17
                            });
                        };
                    };
                    _local15 = new Array();
                    _local15 = Global.world.getObjectsByPredicate(this.matchBonus);
                    if (((_local15) && ((_local15.length > 0)))){
                        _local18 = 0;
                        while (_local18 < _local15.length) {
                            if (_arg1 == _local15[_local18]){
                                _local15.splice(_local18, 1);
                                break;
                            };
                            _local18++;
                        };
                    };
                    for each (_local16 in _local15) {
                        _local19 = getPixelCenter(_local16);
                        _local6 = 0;
                        while (_local6 < this.m_moveHelperList.length) {
                            if (_local16 == this.m_moveHelperList[_local6].m_gameObject){
                                break;
                            };
                            _local6++;
                        };
                        if (_local6 >= this.m_moveHelperList.length){
                            _local6 = this.m_moveHelperList.length;
                            this.m_textFormat.color = _local5;
                            this.m_textFormat.size = _local7;
                            _local8 = new GMObjMoveHelper(_local3, _local16, _local19, this.m_textFormat, _local5, _arg1);
                            this.m_moveHelperList.push(_local8);
                        } else {
                            _local8 = this.m_moveHelperList[_local6];
                        };
                        _local8.m_active = true;
                    };
                };
            } else {
                if (this.m_preview != null){
                    this.fadeThenRemove(this.m_preview);
                    this.m_preview = null;
                };
            };
            var _local10:int;
            while (_local10 < this.m_moveHelperList.length) {
                _local8 = (this.m_moveHelperList[_local10] as GMObjMoveHelper);
                if (!_local8.m_active){
                    if (this.m_positionValid){
                        _local8.showYieldAndDeactivate(this.m_textFormat);
                    } else {
                        _local8.deactivate();
                    };
                    this.m_moveHelperList.splice(_local10, 1);
                    _local10--;
                };
                _local10++;
            };
        }
        private function updateBonuses():void{
            var _local1:MapResource;
            var _local2:Point;
            if ((this.m_selectedObject is MapResource)){
                _local1 = MapResource(this.m_selectedObject);
                if ((((this.m_prevPos.x == this.m_highlightedPoint.x)) && ((this.m_prevPos.y == this.m_highlightedPoint.y)))){
                    return;
                };
                this.showPositioningFeedback(_local1, IsoMath.tilePosToPixelPos(this.m_highlightedPoint.x, this.m_highlightedPoint.y));
                this.m_prevPos.x = this.m_highlightedPoint.x;
                this.m_prevPos.y = this.m_highlightedPoint.y;
                this.m_displayBonusObject.graphics.clear();
                _local2 = getPixelCenter(_local1);
                this.showBonusesAffectingMapObj(_local1, _local2);
                this.showBonusesMapObjApplies(_local1, _local2);
            };
        }
        override public function enableMode():void{
            super.enableMode();
            this.onMouseMove(null);
            GlobalEngine.viewport.objectBase.addChild(this.m_displayBonusObject);
            if (this.m_selectedObject){
                this.m_selectedObject.onMouseOut();
            };
        }
        override public function onMouseMove(_arg1:MouseEvent):Boolean{
            var _local3:Vector2;
            var _local4:Vector3;
            var _local5:DisplayObject;
            var _local6:MapResource;
            var _local7:Number;
            var _local8:Number;
            var _local2:Point = getMouseStagePos();
            if (((((((((!(Global.guide.isActive())) && (this.m_viewDragStartPos))) && (_local2))) && (m_mouseDownPos))) && ((_local2.subtract(m_mouseDownPos).length >= Constants.DRAG_CLICK_EPSILON)))){
                this.m_dragging = true;
            };
            if (((this.m_dragging) && (this.m_viewDragStartPos))){
                _local3 = new Vector2();
                _local3.x = (this.m_viewDragStartPos.x + ((_local2.x - m_mouseDownPos.x) / GlobalEngine.viewport.getZoom()));
                _local3.y = (this.m_viewDragStartPos.y + ((_local2.y - m_mouseDownPos.y) / GlobalEngine.viewport.getZoom()));
                _local3 = limitBackgroundScrolling(_local3);
                GlobalEngine.viewport.setScrollPosition(_local3);
                if (!OptimizationConfig.optimizeCulling){
                    Global.world.updateWorldObjectCulling(GameWorld.CULL_CHECK_ALL);
                };
            } else {
                if (this.m_selectedObject){
                    if (this.m_selectedObject.getOuter() == null){
                        Global.world.popGameMode();
                        return (false);
                    };
                    _local4 = this.m_selectedObject.getPosition();
                    this.m_positionValid = this.updateHighlightPoint(_arg1);
                    if (((!((_local4.x == this.m_highlightedPoint.x))) || (!((_local4.y == this.m_highlightedPoint.y))))){
                        _local5 = this.m_selectedObject.getDisplayObject();
                        if (_local5){
                            _local7 = _local5.x;
                            _local8 = _local5.y;
                        };
                        this.m_selectedObject.setPosition(this.m_highlightedPoint.x, this.m_highlightedPoint.y);
                        this.m_selectedObject.conditionallyReattach();
                        this.m_selectedObject.onObjectDrag(_local4);
                        _local6 = (this.m_selectedObject as MapResource);
                        if (_local6){
                            Global.world.citySim.roadManager.updateResource(_local6);
                            this.m_autoRotate = ((this.m_autoRotate) && (_local6.autoRotate));
                            if (this.m_autoRotate){
                                this.rotateToRoad(_local6);
                            };
                        };
                    };
                };
            };
            this.updateOverlay();
            return (true);
        }
        override public function onMouseDown(_arg1:MouseEvent):Boolean{
            super.onMouseDown(_arg1);
            this.m_viewDragStartPos = GlobalEngine.viewport.getScrollPosition().clone();
            this.m_dragging = false;
            this.m_mouseDownFlag = true;
            this.m_textYOffset = 0;
            this.m_prevPos.x = 9999.2;
            this.m_prevPos.y = 9999.2;
            return (true);
        }
        override public function onMouseUp(_arg1:MouseEvent):Boolean{
            if (((((!(this.m_mouseDownFlag)) && (this.m_selectedObject))) && (this.m_objectStartPos))){
                if (!this.m_objectStartPos.equals(this.m_selectedObject.getPosition())){
                    this.m_mouseDownFlag = true;
                };
                if (this.m_dropImmediately){
                    this.m_mouseDownFlag = true;
                };
            };
            if ((((this.m_dragging == false)) && (this.m_mouseDownFlag))){
                this.onMouseMove(_arg1);
                this.handleObjectDrop(_arg1);
            };
            this.m_dragging = false;
            this.m_viewDragStartPos = null;
            this.m_mouseDownFlag = false;
            if ((this.m_selectedObject is Peddler)){
                if (!Global.isVisiting()){
                    StatsManager.count("peddler_feature", "peddler_moved_by_host");
                };
                if (!this.m_objectPlacedSuccess){
                    Sounds.play("click4");
                };
            };
            if (!this.m_linkedObjectMode){
                super.onMouseUp(_arg1);
            };
            return (true);
        }
        protected function updateHighlightPoint(_arg1:MouseEvent):Boolean{
            this.m_highlightedPoint = getMouseTilePos(_arg1, this.m_objectDragOffset);
            this.snapPoint(this.m_highlightedPoint);
            var _local2:Boolean = this.isPositionValid();
            return (_local2);
        }
        protected function resetOnPlaceCollisions():void{
            this.m_onPlaceFilter = Constants.WORLDOBJECT_NONE;
            this.m_onPlaceCollisions = new Array();
        }
        protected function registerOnPlaceCollision(_arg1:int, _arg2:Function, _arg3:Function):void{
            this.m_onPlaceFilter = (this.m_onPlaceFilter | _arg1);
            this.m_onPlaceCollisions.push({
                arrFilter:_arg2,
                handler:_arg3
            });
        }
        public function rotateToRoad(_arg1:MapResource):void{
            var _local3:uint;
            var _local2:Array = [_arg1.BOTTOM_SIDE, _arg1.LEFT_SIDE, _arg1.RIGHT_SIDE, _arg1.TOP_SIDE];
            for each (_local3 in _local2) {
                if (this.rotateToRoadSide(_arg1, _local3)){
                    break;
                };
            };
        }
        private function checkIsAdjacentRoad(_arg1:MapResource):Boolean{
            var _local3:uint;
            var _local2:Array = [_arg1.BOTTOM_SIDE, _arg1.LEFT_SIDE, _arg1.RIGHT_SIDE, _arg1.TOP_SIDE];
            for each (_local3 in _local2) {
                if (_arg1.isRoadAdjacent(_local3)){
                    return (true);
                };
            };
            return (false);
        }
        private function rotateToRoadSide(_arg1:MapResource, _arg2:uint):Boolean{
            var _local5:int;
            var _local3:Boolean;
            var _local4:int = _arg1.getDirection();
            if (((_arg1.isRoadAdjacent(_arg2)) && (_arg1.sideDirectionMap.hasOwnProperty(_arg2)))){
                _local5 = (_arg1.sideDirectionMap[_arg2] as int);
                if (OptimizationConfig.optimizeRedraw){
                    _arg1.lockRedraw();
                };
                _arg1.rotateToDirection(_local5);
                if (this.isPositionValid()){
                    _local3 = true;
                    if (OptimizationConfig.optimizeRedraw){
                        _arg1.unlockRedraw();
                        _arg1.reloadImage();
                    };
                } else {
                    _arg1.rotateToDirection(_local4);
                    if (OptimizationConfig.optimizeRedraw){
                        _arg1.unlockRedraw();
                    };
                };
            };
            return (_local3);
        }
        private function isMovingPier():Boolean{
            var _local1:ConstructionSite;
            if ((this.m_selectedObject is Pier)){
                return (true);
            };
            if ((this.m_selectedObject is ConstructionSite)){
                _local1 = ConstructionSite(this.m_selectedObject);
                if (_local1.targetClass == Pier){
                    return (true);
                };
            };
            return (false);
        }
        private function isMovingBridge():Boolean{
            var _local1:ConstructionSite;
            if ((this.m_selectedObject is Bridge)){
                return (true);
            };
            if ((this.m_selectedObject is ConstructionSite)){
                _local1 = ConstructionSite(this.m_selectedObject);
                if (_local1.targetItem.type == "bridge"){
                    return (true);
                };
            };
            return (false);
        }
        private function isPierPositionValid():Boolean{
            var _local7:Ship;
            var _local8:Pier;
            var _local9:ConstructionSite;
            var _local10:Pier;
            var _local1:Vector3 = this.m_selectedObject.getSize();
            var _local2 = "";
            var _local3:Number = 8;
            var _local4:Pier;
            if ((this.m_selectedObject is Pier)){
                _local8 = Pier(this.m_selectedObject);
                _local4 = _local8;
                _local2 = _local8.landSquares;
                _local3 = _local8.waterLength;
            };
            if ((this.m_selectedObject is ConstructionSite)){
                _local9 = ConstructionSite(this.m_selectedObject);
                if (_local9.targetClass == Pier){
                    _local10 = new Pier(_local9.targetName);
                    _local4 = _local10;
                    _local2 = _local10.landSquares;
                    _local3 = _local10.waterLength;
                };
            };
            if ((((this.m_highlightedPoint.x > -15)) && ((this.m_highlightedPoint.y > -60)))){
                return (false);
            };
            var _local5:Boolean = Global.world.citySim.waterManager.positionValidPierOnWater(new Rectangle(this.m_highlightedPoint.x, this.m_highlightedPoint.y, _local1.x, _local1.y), _local2, _local3);
            if (!_local5){
                return (_local5);
            };
            var _local6:Array = Global.world.getObjectsByClass(Ship);
            for each (_local7 in _local6) {
                if (_local4.shipCollidedWithDock(new Rectangle(_local7.getPosition().x, _local7.getPosition().y, _local7.getSize().x, _local7.getSize().y))){
                    return (false);
                };
            };
            return (_local5);
        }
        private function isMovingShip():Boolean{
            return ((this.m_selectedObject is Ship));
        }
        private function isShipPositionValid():Boolean{
            var _local3:Ship;
            var _local1:Vector3 = this.m_selectedObject.getSize();
            if (!Global.world.citySim.waterManager.positionValidShipOnWater(new Rectangle(this.m_highlightedPoint.x, this.m_highlightedPoint.y, _local1.x, _local1.y))){
                return (false);
            };
            this.m_collisions = [];
            var _local2:Boolean;
            if (Global.world.checkCollision(this.m_highlightedPoint.x, this.m_highlightedPoint.y, (this.m_highlightedPoint.x + _local1.x), (this.m_highlightedPoint.y + _local1.y), [this.m_selectedObject], this.m_collisions, ~(this.m_onPlaceFilter), this.m_selectedObject)){
                if (this.m_collisions.length > 0){
                    _local2 = false;
                };
            };
            if (!_local2){
                return (false);
            };
            if ((this.m_selectedObject is Ship)){
                this.m_collisions = [];
                _local3 = Ship(this.m_selectedObject);
                return (_local3.isValidShipPosition());
            };
            return (false);
        }
        protected function isBridgePositionValid():Boolean{
            return (false);
        }
        public function isPositionValid(_arg1:Point=null):Boolean{
            var _local5:MapResource;
            if (!_arg1){
                _arg1 = this.m_highlightedPoint;
            };
            var _local2:Vector3 = this.m_selectedObject.getSize();
            var _local3:Boolean;
            if (this.isMovingShip()){
                return (this.isShipPositionValid());
            };
            this.m_collisions = [];
            _local3 = !(Global.world.checkCollision(_arg1.x, _arg1.y, (_arg1.x + _local2.x), (_arg1.y + _local2.y), [this.m_selectedObject], this.m_collisions, ~(this.m_onPlaceFilter), this.m_selectedObject));
            if (this.isMovingBridge()){
                if (this.m_collisions.length == 0){
                    return (this.isBridgePositionValid());
                };
                return (false);
            };
            var _local4:Road = (this.m_selectedObject as Road);
            if (((!(_local3)) && (_local4))){
                _local4.setPosition(_arg1.x, _arg1.y);
                _local3 = _local4.isPositionValid();
                if (_local3){
                    this.m_collisions = [];
                };
            };
            if (_local3){
                _local3 = Global.world.rectInTerritory(new Rectangle(_arg1.x, _arg1.y, _local2.x, _local2.y));
            };
            if (((this.isMovingPier()) && (_local3))){
                return (this.isPierPositionValid());
            };
            _local5 = (this.m_selectedObject as MapResource);
            if (((_local3) && (_local5))){
                _local3 = _local5.checkPlacementRequirements(_arg1.x, _arg1.y);
            };
            return (_local3);
        }
        protected function snapPoint(_arg1:Point):void{
            _arg1.x = Math.round(_arg1.x);
            _arg1.y = Math.round(_arg1.y);
            if (this.m_selectedObject){
                _arg1.x = (_arg1.x - (_arg1.x % this.m_selectedObject.getSnapX()));
                _arg1.y = (_arg1.y - (_arg1.y % this.m_selectedObject.getSnapY()));
            };
        }
        protected function replaceResource(_arg1:MapResource):void{
        }
        protected function handleObjectDrop(_arg1:MouseEvent=null):void{
            var _local2:Vector3;
            var _local3:Road;
            var _local4:Vector3;
            var _local5:Vector3;
            var _local6:Array;
            var _local7:Object;
            var _local8:Road;
            var _local9:Array;
            var _local10:Boolean;
            this.m_positionValid = (_arg1) ? this.updateHighlightPoint(_arg1) : true;
            if (this.m_positionValid){
                if (this.m_objectStartPos != null){
                    if (!this.isPositionValid(new Point(this.m_objectStartPos.x, this.m_objectStartPos.y))){
                        if (this.m_backupStartPosition){
                            this.m_objectStartPos = this.m_backupStartPosition;
                        };
                    };
                };
                _local2 = this.m_objectStartPos;
                this.m_releasedPoint = new Vector2();
                if (_arg1){
                    this.m_releasedPoint.x = this.m_highlightedPoint.x;
                    this.m_releasedPoint.y = this.m_highlightedPoint.y;
                } else {
                    this.m_releasedPoint.x = this.m_objectStartPos.x;
                    this.m_releasedPoint.y = this.m_objectStartPos.y;
                    _local2 = this.m_selectedObject.getPosition();
                    if ((this.m_selectedObject as MapResource)){
                        (this.m_selectedObject as MapResource).rotateToDirection(this.m_oldDirection);
                    } else {
                        this.m_selectedObject.setDirection(this.m_oldDirection);
                    };
                };
                _local3 = (this.m_selectedObject as Road);
                if (_local3 != null){
                    _local8 = _local3.prepareToDrop(_local2, this.m_releasedPoint);
                    if (_local8 != _local3){
                        this.m_selectedObject = _local8;
                        this.replaceResource(_local8);
                        if (_local8 == null){
                            this.m_objectPlacedSuccess = false;
                            this.onObjectDropCompleted();
                            return;
                        };
                    };
                };
                _local4 = this.m_selectedObject.getSize();
                _local5 = this.m_selectedObject.getPosition();
                this.snapPoint(this.m_releasedPoint);
                _local6 = new Array();
                Global.world.checkCollision(_local5.x, _local5.y, (_local5.x + _local4.x), (_local5.y + _local4.y), [this.m_selectedObject], _local6, this.m_onPlaceFilter, this.m_selectedObject);
                if (_local6.length == 0){
                    this.completeObjectDrop();
                    return;
                };
                for each (_local7 in this.m_onPlaceCollisions) {
                    _local9 = _local6.filter(_local7.arrFilter);
                    _local7.handler(_local9, (_local6.length - _local9.length));
                };
            } else {
                if (_arg1){
                    _local10 = Global.world.rectInTerritory(new Rectangle(this.m_highlightedPoint.x, this.m_highlightedPoint.y, this.m_selectedObject.getSize().x, this.m_selectedObject.getSize().y));
                    if (!_local10){
                        UI.displayStatus(ZLoc.t("Main", "BuyExpansionFirstRed"), _arg1.stageX, _arg1.stageY);
                        Global.ui.showTickerMessage(ZLoc.t("Main", "TickerBuyExpansion"));
                    };
                };
            };
        }
        protected function objectSellCallback(_arg1:GameObject):void{
            if ((((_arg1 is Road)) && ((this.m_selectedObject is Road)))){
                this.completeObjectDrop();
            };
        }
        protected function completeObjectDrop():void{
            var _local3:Object;
            var _local4:LotSite;
            var _local1:MapResource = (this.m_selectedObject as MapResource);
            var _local2:Boolean = _local1.isPlacedObjectNonBuilding();
            if (((this.m_objectStartPos) && (this.m_releasedPoint))){
                _local3 = new Object();
                _local3.x = Math.round(this.m_releasedPoint.x);
                _local3.y = Math.round(this.m_releasedPoint.y);
                _local3.state = _local1.getState();
                _local3.direction = _local1.getDirection();
                _local3 = _local1.addTMoveParams(_local3);
                if (!this.m_linkedObjectMode){
                    GameTransactionManager.addTransaction(new TMove(_local1, _local3));
                };
                if (((!((this.m_objectStartPos.x == this.m_releasedPoint.x))) || (!((this.m_objectStartPos.y == this.m_releasedPoint.y))))){
                    _local1.trackDetailedAction(TrackedActionType.MOVE, "successful", "");
                } else {
                    _local1.trackDetailedAction(TrackedActionType.MOVE, "unsuccessful", "");
                };
                _local1.trackDetailedAction(TrackedActionType.MOVE, "age", "", _local1.getAge());
            };
            this.m_selectedObject.setPosition(Math.round(this.m_releasedPoint.x), Math.round(this.m_releasedPoint.y));
            this.m_selectedObject.conditionallyReattach();
            this.m_selectedObject.onObjectDrop(this.m_objectStartPos);
            this.m_objectPlacedSuccess = true;
            if (!this.m_linkedObjectMode){
                if (_local2){
                    Sounds.play("click4");
                } else {
                    Sounds.play("place_building");
                };
            };
            if ((_local1 is LotSite)){
                _local4 = (_local1 as LotSite);
                MarketCell.reLockCells(_local4.getItem().name);
            };
            this.onObjectDropCompleted();
        }
        protected function onObjectDropCompleted():void{
            if (this.m_linkedObjectMode){
                return;
            };
            if (this.m_exitAfterDrop){
                Global.world.addGameMode(new GMPlay(), true);
            } else {
                Global.world.popGameMode();
            };
        }
        public function drawArea(_arg1:Graphics, _arg2:Number, _arg3:Number):void{
            var _local4:Vector2 = IsoMath.getPixelDeltaFromTileDelta(_arg2, 0);
            var _local5:Vector2 = IsoMath.getPixelDeltaFromTileDelta(0, _arg3);
            _arg1.moveTo(0, 0);
            _arg1.lineTo((0 + _local4.x), (0 + _local4.y));
            _arg1.lineTo(((0 + _local4.x) + _local5.x), ((0 + _local4.y) + _local5.y));
            _arg1.lineTo((0 + _local5.x), (0 + _local5.y));
            _arg1.lineTo(0, 0);
        }
        protected function updateOverlay():void{
            var _local1:Vector3;
            var _local2:uint;
            var _local3:GuideTile;
            var _local4:Point;
            var _local5:Vector3;
            var _local6:MapResource;
            m_displayObject.graphics.clear();
            if (this.m_highlightedPoint){
                _local1 = this.m_selectedObject.getSize();
                _local2 = (this.m_positionValid) ? Constants.COLOR_VALID_PLACEMENT : Constants.COLOR_NOT_VALID_PLACEMENT;
                if (((((this.m_positionValid) && ((this.m_selectedObject is MapResource)))) && ((this.m_selectedObject as MapResource).isNeedingRoad))){
                    _local2 = COLOR_NO_ROAD_CONNECT;
                    this.m_isNearRoad = false;
                } else {
                    this.m_isNearRoad = true;
                };
                if (true == (this.m_selectedObject as MapResource).isNotAtRoad()){
                    _local2 = Constants.COLOR_NOT_VALID_PLACEMENT;
                };
                if (Global.guide.isActive()){
                    for each (_local3 in Global.guide.guideTiles) {
                        if (_local3.origin.equals(this.m_selectedObject.getPosition())){
                            _local2 = Constants.COLOR_VALID_PLACEMENT;
                        } else {
                            _local2 = Constants.COLOR_NOT_VALID_PLACEMENT;
                        };
                    };
                };
                m_displayObject.graphics.lineStyle(TILE_OUTLINE_WIDTH, _local2, Constants.ALPHA_VALID_PLACEMENT);
                drawTileArea(m_displayObject.graphics, this.m_highlightedPoint, _local1.x, _local1.y);
                if (!this.m_positionValid){
                    _local4 = new Point();
                    m_displayObject.graphics.lineStyle(TILE_OUTLINE_WIDTH, Constants.COLOR_NOT_VALID_PLACEMENT, Constants.ALPHA_VALID_PLACEMENT);
                    for each (_local6 in this.m_collisions) {
                        _local1 = _local6.getSize();
                        _local5 = _local6.getPosition();
                        _local4.x = _local5.x;
                        _local4.y = _local5.y;
                        drawTileArea(m_displayObject.graphics, _local4, _local1.x, _local1.y);
                    };
                };
            };
            this.updateBonuses();
        }
        override public function disableMode():void{
            var _local1:GMObjMoveHelper;
            if (this.m_selectedLocked){
                this.m_selectedObject.unlock();
                this.m_selectedLocked = false;
            };
            if ((((((((this.m_objectPlacedSuccess == false)) && ((this.m_objectStoredSuccess == false)))) && (this.m_selectedObject))) && (!((this.m_selectedObject.getOuter() == null))))){
                if (this.m_objectStartPos == null){
                    this.m_selectedObject.detach();
                    this.m_selectedObject.cleanup();
                } else {
                    this.handleObjectDrop();
                };
            };
            if (this.m_displayBonusObject){
                this.fadeThenRemove(this.m_displayBonusObject);
            };
            if (this.m_preview){
                this.fadeThenRemove(this.m_preview);
                this.m_preview = null;
            };
            if (this.m_positionFeedback){
                this.fadeThenRemove(this.m_positionFeedback);
                this.m_positionFeedback = null;
            };
            this.endAreasOfEffect();
            for each (_local1 in this.m_moveHelperList) {
                _local1.deactivate();
            };
            this.m_moveHelperList.length = 0;
            GMObjMoveHelper.deactivateAllPending();
            super.disableMode();
        }
        public function setLinkedObjectMode(_arg1:Boolean):void{
            this.m_linkedObjectMode = _arg1;
        }

    }
}//package GameMode 
